package com.sskj.market.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.market.bean.AddressBean;
import com.sskj.market.ui.activity.EditorDetailAddressActivity;


/**
 * @author Hey
 * Create at  2019/07/26
 */
public class EditorDetailAddressPresenter extends BasePresenter<EditorDetailAddressActivity> {

    public void getAddressData(int id,boolean flag) {
        httpService.getAddressData(id)
                .tag(this)
                .execute(new JsonCallBack<HttpData<AddressBean>>(flag?this:null) {
                    @Override
                    public void onSuccess(Response<HttpData<AddressBean>> response) {
                        AddressBean data = response.body().getData();
                        mView.getAddressDataSuccess(data);
                    }
                });
    }

    public void EditorAddress(int id, String name, String phone, String province, String city, String region, String detail, String is_default,boolean flag) {
        httpService.addEditorAddress(id,name,phone,province,city,region,detail,is_default)
                .tag(this)
                .execute(new JsonCallBack<HttpData>(flag?this:null) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        mView.editorAddressSuccess();
                    }
                });
    }
}
